﻿#include "CommSignalSlot.h"
#include "quiwidget.h"

#include <QAbstractSocket>

CommSignalSlot* CommSignalSlot::Instance()
{
    static CommSignalSlot slot;

    return &slot;
}

CommSignalSlot::CommSignalSlot()
{
    qRegisterMetaType<CommSignalSlot::logType>("comm logType");
    qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
}


void CommSignalSlot::CommSlotLog(enum logType type, const QString& title, const QString& log)
{
    QString msg = "";

    switch(type)
    {
    case logSTR:
        msg = QString("%1:%2").arg(title).arg(log);
        break;
    case logDateTime:
        msg = QString("[%1]%2:%3").arg(MyDATETIMEMS).arg(title).arg(log);
        break;
    default: break;
    }

    if(!msg.isEmpty()) emit CommSignalLog(msg);
}
